__author__ = 'wangtao'
import math
import getContent__computePointsForCandidate__do

def getContent__computePointsForCandidate(_e, _main):

    _details = _e['__candidate_details']
    _points_history = []
    _really_big = (_main['_length__plain_text'] / 65) > 250

#    坏候选人
    if (_e['_is__bad']) :
        return {0}

#    基础知识
    _points_history.append(((0
        + _details['_count__paragraphs_of_3_lines']
        + (_details['_count__paragraphs_of_5_lines'] * 1.5)
        + _details['_count__paragraphs_of_50_words']
        + _details['_count__paragraphs_of_80_words']
        + (_e['_count__images_large'] * 3)
        - ((_e['_count__images_skip'] + _e['_count__images_small']) * 0.5))
        * 1000
        ))

#    为负
    if _points_history[0] < 0 :
        return {0}

#    候选人和容器
    _divide__pieces = max(5, math.ceil(_e['_count__pieces'] * 0.25))
    _divide__candidates = max(5, math.ceil(_e['_count__candidates'] * 0.25))
    _divide__containers = max(10, math.ceil(_e['_count__containers'] * 0.25))

    _points_history.append(((0
        + _points_history[0] * 3
        + _points_history[0] / _divide__pieces
        + _points_history[0] / _divide__candidates
        + _points_history[0] / _divide__containers
    ) / 6))

#    总文本
    _points_history = getContent__computePointsForCandidate__do(0.10, 2, (1 - (1 - _details['_ratio__length__plain_text_to_total_plain_text'])), _points_history)

    _points_history = getContent__computePointsForCandidate__do(0.10, 2, (1 - (1 - _details['_ratio__count__plain_words_to_total_plain_words'])), _points_history)

    if _really_big :
        _points_history = getContent__computePointsForCandidate__do(0.10, 4, (1 - (1 - _details['_ratio__length__plain_text_to_total_plain_text'])), _points_history)
        _points_history = getContent__computePointsForCandidate__do(0.10, 4, (1 - (1 - _details['_ratio__count__plain_words_to_total_plain_words'])), _points_history)

    # text above
    _points_history = getContent__computePointsForCandidate__do(0.10, 5, (1 - _details['_ratio__length__above_plain_text_to_total_plain_text']), _points_history)
    _points_history = getContent__computePointsForCandidate__do(0.10, 5, (1 - _details['_ratio__count__above_plain_words_to_total_plain_words']), _points_history)

    if _really_big :
        _points_history = getContent__computePointsForCandidate__do(0.10, 10, (1 - _details['_ratio__length__above_plain_text_to_total_plain_text']), _points_history)
        _points_history = getContent__computePointsForCandidate__do(0.10, 10, (1 - _details['_ratio__count__above_plain_words_to_total_plain_words']), _points_history)

#    链接外
    getContent__computePointsForCandidate__do(0.75, 1, (1 - _details['_ratio__length__links_text_to_total_links_text']), _points_history)
    getContent__computePointsForCandidate__do(0.75, 1, (1 - _details['_ratio__count__links_words_to_total_links_words']), _points_history)

    getContent__computePointsForCandidate__do(0.75, 1, (1 - _details['_ratio__count__links_to_total_links']), _points_history)

#    链接内
#__lr = ($R.language == 'cjk' ? 0.75 : 0.50);
    __lr = 0.50

    getContent__computePointsForCandidate__do(__lr, 1, (1 - _details['_ratio__length__links_text_to_plain_text']), _points_history)
    getContent__computePointsForCandidate__do(__lr, 1, (1 - _details['_ratio__count__links_words_to_plain_words']), _points_history)

    getContent__computePointsForCandidate__do(__lr, 1, (1 - _details['_ratio__length__links_text_to_all_text']), _points_history)
    getContent__computePointsForCandidate__do(__lr, 1, (1 - _details['_ratio__count__links_words_to_all_words']), _points_history)

    getContent__computePointsForCandidate__do(__lr, 1, (1 - _details['_ratio__count__links_to_plain_words']), _points_history)

#   候选人，件
    getContent__computePointsForCandidate__do(0.75, 1, (1 - _details['_ratio__count__candidates_to_total_candidates']), _points_history)
    getContent__computePointsForCandidate__do(0.75, 1, (1 - _details['_ratio__count__containers_to_total_containers']), _points_history)
    getContent__computePointsForCandidate__do(0.75, 1, (1 - _details['_ratio__count__pieces_to_total_pieces']), _points_history)

    return _points_history




